#include <iostream>
#include <sstream>
#include <vector>

struct DataPackage{
    int para_1;
    float para_2;
    std::vector<double> para_3;
};

std::string serialization_datapackage(const DataPackage& _package){
    std::stringstream ss;
    ss << _package.para_1 << " ";
    ss << _package.para_2 << " ";
    ss << _package.para_3.size() << " ";
    for(const double& val : _package.para_3)
        ss << val << " ";
    return ss.str();
}

DataPackage de_serialization_datapackage(const std::string& _datas){
    std::stringstream ss;
    ss.str(_datas);
    DataPackage package;
    ss >> package.para_1;
    ss >> package.para_2;
    int counter;
    ss >> counter;
    package.para_3.resize(counter);
    for(int i = 0; i < counter; i++){
        int val;
        ss >> val;
        package.para_3[i] = val;
    }
    return package;
}

int main(){
    DataPackage p;
    p.para_1 = 99;
    p.para_2 = 1001;
    p.para_3.push_back(120);
    p.para_3.push_back(130);

    std::string s = serialization_datapackage(p);

    std::cout << s << std::endl;

    DataPackage p_c = de_serialization_datapackage(s);

    std::cout << p_c.para_1 << "   " << p_c.para_2 << "   ";
    for(int i = 0; i < p_c.para_3.size(); i++){
        std::cout << p_c.para_3[i] << "   ";
    }
    std::cout << std::endl;
}
